package com.hzqy.service.epg;

import com.hzqy.persistence.dao.epg.AcConfigDao;
import com.hzqy.persistence.dao.epg.AcStbUserVoteNumDao;
import com.hzqy.web.vo.epg.AcConfigVo;
import com.hzqy.web.vo.epg.AcStbUserVoteNumVo;
import com.hzqy.web.vo.epg.ActivityProductVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AcStbUserVoteNumService {
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	@Resource
	private AcStbUserVoteNumDao acDao;
	public  Map<String,Object> selectAc(AcStbUserVoteNumVo acv, int page, int rows){
        Map<String,Object> map=new HashMap<String, Object>();
        map.put("f_asuv_serverid",acv.getF_asuv_serverid());
        map.put("f_asuv_activityid",acv.getF_asuv_activityid());
        map.put("f_asuv_source", acv.getF_asuv_source());
        map.put("f_asuv_cdate", acv.getF_asuv_cdate());
        map.put("f_asuv_resolution",acv.getF_asuv_resolution());
        map.put("beginDate", acv.getBeginDate());
        map.put("endDate", acv.getEndDate());
        Integer rowCount = acDao.selectAcCount(map);
        map.put("total", rowCount);
        if(rowCount>0 && page>0 && rows>0){
            map.put("firstResult", (page-1)*rows);
            map.put("maxResults", rows);
            List<AcStbUserVoteNumVo> list=acDao.selectAcByRequest(map);
            map.put("rows", list);
        }else{
            map.put("rows", new ArrayList<AcConfigVo>());
        }
        return map;
	}
    public Integer StbVoteNumInsert(AcStbUserVoteNumVo acv){
        Map<String,String> map=new HashMap<String,String>();
        map.put("f_asuv_activityid",acv.getF_asuv_activityid());
        if("高清".equals(acv.getF_asuv_resolution())){
            map.put("f_asuv_resolution","2");
        }else{
            map.put("f_asuv_resolution","1");
        }
        map.put("f_asuv_serverid",acv.getF_asuv_serverid());
        map.put("f_asuv_votenum",acv.getF_asuv_votenum());
       return acDao.updateAcVoteNum(map);
    }
    public Integer insetAcVoteNum(AcStbUserVoteNumVo acv){
       return acDao.insetAcVoteNum(acv);
    }
    public AcStbUserVoteNumVo selectById(AcStbUserVoteNumVo apv){
	    Map<String,String> map=new HashMap<String,String>();
	    map.put("f_asuv_id",apv.getF_asuv_id());
        return acDao.selectAcRequest(apv);
    }
}
